<?php
if ( !defined( "IN_OP" ) )
{
    exit( "You can't access this file directly..." );
}
if ( isset( $_SESSION['subaccount'] ) )
{
    $ui->showErrorPage( "你是子帐号，不能执行这个功能！" );
    exit();
}
$ui = new ui();
$tpl = new Template2();
if ( isset( $_GET['mod'] ) )
{
    $mod = intval( $_GET['mod'] );
}
else
{
    $mod = "";
}
if ( $mod == 0 )
{
    if ( ispost( ) )
    {
        $temp = $_POST['qcnum'];
        if ( $temp != "" )
        {
            $num_r = explode( ",", $temp );
            $money = intval( $_POST['nts'] );
            $f = array();
            $i = 0;
            while ( $i < count( $num_r ) )
            {
                $n = d2( intval( $num_r[$i] ) );
                if ( "01" <= $n && $n <= "49" )
                {
                    $f["r".$n] = $money;
                }
                ++$i;
            }
            db_update( "maxbet0", $f, "user_id=0" );
        }
    }
    exit();
}
$tpl->load( "main", "maxmoney.htm" );
if ( ispost( ) )
{
    $fields = array();
    $i = 1;
    while ( $i < 50 )
    {
        $ii = d2( $i );
        $temp = floatval( $_POST["r0_".$ii] );
        $fields["r".$ii] = $temp;
        ++$i;
    }
    $sql = "update maxbet0 set ";
    foreach ( $fields as $key => $temp )
    {
        $sql .= " {$key}={$temp}, ";
    }
    if ( substr( $sql, 0 - 2 ) == ", " )
    {
        $sql = substr( $sql, 0, strlen( $sql ) - 2 );
    }
    $sql .= " WHERE user_id=0";
    getdb( $sql );
}
$tpl->set( "action", "?".$_SERVER['QUERY_STRING'] );
$rs = getdb( "select * from maxbet0 WHERE user_id=0" );
if ( $rs->eof )
{
    getdb( "insert into maxbet0 (user_id) values (0)" );
    $rs = getdb( "select * from maxbet0 WHERE user_id=0" );
}
$i = 1;
while ( $i < 50 )
{
    $ii = d2( $i );
    $tpl->set( "r0_".$ii, $rs->f["r".$ii] - 0 );
    ++$i;
}
$rs->close();
$tpl->show( "main" );
?>